home *** CD-ROM | disk | FTP | other *** search
/ Power CD / Power CD ATARI-Rechner Lieben.iso / DEMOS / NO / INTERFAC / GEISS_2 / EXTOBFIX.C next >
Encoding:
C/C++ Source or Header  |  1992-08-10  |  19.0 KB  |  689 lines

  1. /*****************************************************************************/
  2. /*                                                                           */
  3. /* Modul: EXTOBFIX.C                                                         */
  4. /* Datum: 17.02.91                                                           */
  5. /*                                                                           */
  6. /*****************************************************************************/
  7.  
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <portab.h>
  11. #include <aes.h>
  12. #include <vdi.h>
  13.  
  14. #include "extobfix.h"
  15.  
  16. /****** DEFINES **************************************************************/
  17.  
  18. #ifndef RSC_NAME
  19. #define RSC_NAME   "EXTOBFIX.RSC"      /* Name der Resource-Datei */
  20. #endif
  21.  
  22. #ifndef max
  23. #define max(a,b)    (((a) > (b)) ? (a) : (b)) /* Maximum-Funktion */
  24. #define min(a,b)    (((a) < (b)) ? (a) : (b)) /* Minimum Funktion */
  25. #endif
  26.  
  27. #define DHEADER    0x0020
  28. #define DHEIGHT    0x0040
  29. #define DCRBUTTON  0x0080
  30.  
  31. #define HALFSTRSIZE 128        /* Halblange Stringgröße */
  32. #define DESK          0        /* Window-Handle/Klasse des Desktop als Objekt */
  33. #define RC            2        /* Raster Koordinaten */
  34.  
  35. /****** TYPES ****************************************************************/
  36.  
  37. typedef struct
  38. {
  39.   WORD bgc;
  40.   WORD style;
  41.   WORD interior;
  42.   WORD bdc;
  43.   WORD width;
  44.   WORD chc;
  45. } OBINFO;
  46.  
  47. typedef struct
  48. {
  49.   WORD x;                                 /* X-Koordinate */
  50.   WORD y;                                 /* Y-Koordinate */
  51.   WORD w;                                 /* Breite */
  52.   WORD h;                                 /* Höhe */
  53. } RECT;
  54.  
  55. typedef BYTE STR128 [HALFSTRSIZE];        /* Halblange Zeichenkette */
  56.  
  57. /****** VARIABLES ************************************************************/
  58.  
  59. #if DR_C | LASER_C | MW_C
  60. EXTERN WORD   gl_apid;                   /* Identifikation für Applikation */
  61. #else
  62. LOCAL WORD    gl_apid;                   /* Identifikation für Applikation */
  63. #endif
  64.  
  65. LOCAL USERBLK check_blk;                /* used for Macintosh check boxes */
  66. LOCAL USERBLK radio_blk;                /* used for Macintosh radio buttons */
  67.  
  68. LOCAL WORD    gl_wbox;                   /* Breite einer Zeichenbox */
  69. LOCAL WORD    gl_hbox;                   /* Höhe einer Zeichenbox */
  70. LOCAL WORD    gl_wattr;                  /* Breite eines Fensterattributes */
  71. LOCAL WORD    gl_hattr;                  /* Höhe eines Fensterattributes */
  72.  
  73. LOCAL WORD    phys_handle;               /* Physikalisches Workstation Handle */
  74. LOCAL WORD    vdi_handle;                /* Virtuelles Workstation Handle */
  75. LOCAL BOOLEAN vwork_open;                /* Virtuelle Workstation geöffnet ? */
  76.  
  77. LOCAL RECT    desk;                      /* Desktop Größe */
  78. LOCAL RECT    clip;                      /* Letztes Clipping Rechteck */
  79.  
  80. LOCAL OBJECT  *userimg;
  81.  
  82. /****** FUNCTIONS ************************************************************/
  83.  
  84. GLOBAL LONG       pinit_obfix   _((BOOLEAN status));
  85. LOCAL  VOID       fix_objs      _((OBJECT  *tree, BOOLEAN is_dialog));
  86. LOCAL  VOID       xywh2rect     _((WORD x, WORD y, WORD w, WORD h, RECT *rect));
  87. LOCAL  VOID       set_clip      _((BOOLEAN flag, CONST RECT *size));
  88. LOCAL  VOID       trans_gimage  _((OBJECT *tree, WORD obj));
  89. LOCAL  VOID       rc_copy       _((CONST RECT *ps, RECT *pd));
  90. LOCAL  BOOLEAN    rc_intersect  _((CONST RECT *p1, RECT *p2));
  91. LOCAL  VOID       rect2array    _((CONST RECT *rect, WORD *array));
  92. LOCAL  VOID       xywh2array    _((WORD x, WORD y, WORD w, WORD h, WORD *array));
  93. LOCAL  VOID       open_vwork    _((VOID));
  94. LOCAL  VOID       close_vwork   _((VOID));
  95. LOCAL  BOOLEAN    init_global   _((INT argc, BYTE *argv [], BYTE *acc_menu, WORD class));
  96. LOCAL  BOOLEAN    term_global   _((VOID));
  97.  
  98. LOCAL  VOID       get_obinfo    _((LONG obspec, OBINFO *obinfo));
  99.  
  100. LOCAL WORD CDECL  draw_checkbox _((FAR PARMBLK *pb));
  101. LOCAL WORD CDECL  draw_rbutton  _((FAR PARMBLK *pb));
  102.  
  103. LOCAL  VOID       vdi_fix       _((MFDB *pfd, VOID *theaddr, WORD wb, WORD h));
  104. LOCAL  VOID       vdi_trans     _((WORD *saddr, WORD swb, WORD *daddr, WORD dwb, WORD h));
  105.  
  106. /*****************************************************************************/
  107.  
  108. LOCAL LONG routines[] =
  109. {    (LONG)fix_objs,                    /* Eigene ob_fix Routine */
  110.     0L,                                            /* Keine eigene form_alert Routine */
  111.     0L,                                            /* Keine eigene Testroutine */
  112.     0L,                     /* Noch keine Hilfeseite */
  113.     '0610', '1965',         /* Magic */
  114.     (LONG)pinit_obfix,
  115. };
  116.  
  117. /*****************************************************************************/
  118.  
  119. LOCAL VOID get_obinfo (obspec, obinfo)
  120. LONG   obspec;
  121. OBINFO *obinfo;
  122.  
  123. {
  124.   WORD colorwd;
  125.  
  126.   colorwd       = (WORD)obspec;
  127.   obinfo->bgc   = colorwd & 0x0F;
  128.   obinfo->style = (colorwd & 0x70) >> 4;
  129.  
  130.   if (obinfo->style == 0)
  131.     obinfo->interior = 0;
  132.   else
  133.     if (obinfo->style == 7)
  134.       obinfo->interior = 1;
  135.     else
  136.       obinfo->interior = (colorwd & 0x80) ? 3 : 2;
  137.  
  138.   obinfo->bdc   = (colorwd & 0xF000) >> 12;
  139.   obinfo->width = (WORD)(obspec >> 16) & 0xFF;
  140.  
  141.   if (obinfo->width > 127) obinfo->width = 256 - obinfo->width;
  142.  
  143.   obinfo->chc = (colorwd & 0x0F00) >> 8;
  144. } /* get_obinfo */
  145.  
  146. /*****************************************************************************/
  147. /* Zeichnet ankreuzbare Buttons                                              */
  148. /*****************************************************************************/
  149.  
  150. LOCAL WORD CDECL draw_checkbox (pb)
  151. FAR PARMBLK *pb;
  152.  
  153. { LONG    ob_spec;
  154.   WORD    ob_x, ob_y;
  155.   BOOLEAN selected;
  156.   MFDB    s, d;
  157.   BITBLK  *bitblk;
  158.   WORD    obj;
  159.   WORD    pxy [8];
  160.   WORD    index [2];
  161.   RECT    r;
  162.   OBINFO  obinfo;
  163.  
  164.   ob_spec   = pb->pb_parm;
  165.   ob_x      = pb->pb_x;
  166.   ob_y      = pb->pb_y;
  167.   selected  = pb->pb_currstate & SELECTED;
  168.  
  169.   get_obinfo (ob_spec, &obinfo);
  170.   xywh2rect (pb->pb_xc, pb->pb_yc, pb->pb_wc, pb->pb_hc, &r);
  171.   set_clip (TRUE, &r);
  172.  
  173.   if (selected) /* it was an objc_change */
  174.     obj = (gl_hbox > 8) ? CBHSEL : CBLSEL;   /* high resolution : low resolution */
  175.   else
  176.     obj = (gl_hbox > 8) ? CBHNORM : CBLNORM; /* high resolution : low resolution */
  177.  
  178.   bitblk = (BITBLK *)userimg [obj].ob_spec;
  179.  
  180.   d.mp  = NULL; /* screen */
  181.   s.mp  = (VOID *)bitblk->bi_pdata;
  182.   s.fwp = bitblk->bi_wb << 3;
  183.   s.fh  = bitblk->bi_hl;
  184.   s.fww = bitblk->bi_wb >> 1;
  185.   s.ff  = FALSE;
  186.   s.np  = 1;
  187.  
  188.   pxy [0] = 0;
  189.   pxy [1] = 0;
  190.   pxy [2] = s.fwp - 1;
  191.   pxy [3] = s.fh - 1;
  192.   pxy [4] = ob_x;
  193.   pxy [5] = ob_y;
  194.   pxy [6] = ob_x + pxy [2];
  195.   pxy [7] = ob_y + pxy [3];
  196.  
  197.   index [0] = obinfo.bgc;
  198.   index [1] = WHITE;
  199.  
  200.   vrt_cpyfm (vdi_handle, MD_REPLACE, pxy, &s, &d, index);    /* copy it */
  201.  
  202.   return (pb->pb_currstate & ~ SELECTED);
  203. } /* draw_checkbox */
  204.  
  205. /*****************************************************************************/
  206. /* Zeichnet runde Radiobuttons                                               */
  207. /*****************************************************************************/
  208.  
  209. LOCAL WORD CDECL draw_rbutton (pb)
  210. FAR PARMBLK *pb;
  211.  
  212. { LONG    ob_spec;
  213.   WORD    ob_x, ob_y;
  214.   BOOLEAN selected;
  215.   MFDB    s, d;
  216.   BITBLK  *bitblk;
  217.   WORD    obj;
  218.   WORD    pxy [8];
  219.   WORD    index [2];
  220.   RECT    r;
  221.   OBINFO  obinfo;
  222.  
  223.   ob_spec   = pb->pb_parm;
  224.   ob_x      = pb->pb_x;
  225.   ob_y      = pb->pb_y;
  226.   selected  = pb->pb_currstate & SELECTED;
  227.  
  228.   get_obinfo (ob_spec, &obinfo);
  229.   xywh2rect (pb->pb_xc, pb->pb_yc, pb->pb_wc, pb->pb_hc, &r);
  230.   set_clip (TRUE, &r);
  231.  
  232.   if (selected) /* it was an objc_change */
  233.     obj = (gl_hbox > 8) ? RBHSEL : RBLSEL; /* high resolution : low resolution */
  234.   else
  235.     obj = (gl_hbox > 8) ? RBHNORM : RBLNORM; /* high resolution : low resolution */
  236.  
  237.   bitblk = (BITBLK *)userimg [obj].ob_spec;
  238.  
  239.   d.mp  = NULL; /* screen */
  240.   s.mp  = (VOID *)bitblk->bi_pdata;
  241.   s.fwp = bitblk->bi_wb << 3;
  242.   s.fh  = bitblk->bi_hl;
  243.   s.fww = bitblk->bi_wb >> 1;
  244.   s.ff  = FALSE;
  245.   s.np  = 1;
  246.  
  247.   pxy [0] = 0;
  248.   pxy [1] = 0;
  249.   pxy [2] = s.fwp - 1;
  250.   pxy [3] = s.fh - 1;
  251.   pxy [4] = ob_x;
  252.   pxy [5] = ob_y;
  253.   pxy [6] = ob_x + pxy [2];
  254.   pxy [7] = ob_y + pxy [3];
  255.  
  256.   index [0] = obinfo.bgc;
  257.   index [1] = WHITE;
  258.  
  259.   vrt_cpyfm (vdi_handle, MD_REPLACE, pxy, &s, &d, index);    /* copy it */
  260.  
  261.   return (pb->pb_currstate & ~ SELECTED);
  262. } /* draw_rbutton */
  263.  
  264. /*****************************************************************************/
  265.  
  266. LOCAL VOID fix_objs (tree, is_dialog)
  267. OBJECT  *tree;
  268. BOOLEAN is_dialog;
  269.  
  270. {
  271.   WORD    obj;
  272.   OBJECT  *ob;
  273.   ICONBLK *ib;
  274.   BITBLK  *bi;
  275.   WORD    y_radio, h_radio;
  276.   WORD    y_check, h_check;
  277.   BOOLEAN hires;
  278.   UWORD   type, xtype;
  279. #if GEM & (GEM2 | GEM3 | XGEM)
  280.   BYTE    *s;
  281. #endif
  282.  
  283.   hires   = (gl_hbox > 8) ? TRUE : FALSE;
  284.  
  285.   obj     = hires ? RBHNORM : RBLNORM;
  286.   bi      = (BITBLK *)userimg [obj].ob_spec;
  287.   h_radio = bi->bi_hl;
  288.   y_radio = (gl_hbox - h_radio) / 2;
  289.  
  290.   obj     = hires ? CBHNORM : CBLNORM;
  291.   bi      = (BITBLK *)userimg [obj].ob_spec;
  292.   h_check = bi->bi_hl;
  293.   y_check = (gl_hbox - h_check) / 2;
  294.  
  295.   check_blk.ub_code = draw_checkbox;
  296.   radio_blk.ub_code = draw_rbutton;
  297.  
  298.   if (tree != NULL)
  299.   {
  300. #if GEM & (GEM2 | GEM3 | XGEM)
  301.     if (is_dialog)
  302.     {
  303.       undo_state (tree, ROOT, SHADOWED);
  304.       do_state (tree, ROOT, OUTLINED);
  305.     } /* if */
  306. #endif
  307.  
  308.     obj = NIL;
  309.  
  310.     do
  311.     {
  312.       ob    = &tree [++obj];
  313.       type  = ob->ob_type & 0xFF;
  314.       xtype = ob->ob_type >> 8;
  315.  
  316.  
  317. #if GEM & (GEM2 | GEM3 | XGEM)
  318.       if ((type == G_STRING) && (ob->ob_state & DISABLED))
  319.         for (s = (BYTE *)ob->ob_spec; *s; s++)
  320.           if (*s == 0x13) *s = '-';
  321. #endif
  322.  
  323.       if (type == G_ICON)
  324.       {
  325.         ib = (ICONBLK *)ob->ob_spec;
  326.         ob->ob_height = ib->ib_ytext + ib->ib_htext; /* Objekthöhe = Iconhöhe */
  327.         trans_gimage (tree, obj);         /* Icons an Bildschirm anpassen */
  328.       } /* if */
  329.  
  330.       if (type == G_IMAGE)
  331.       {
  332.         bi = (BITBLK *)ob->ob_spec;
  333.         ob->ob_height = bi->bi_hl;        /* Objekthöhe = Imagehöhe */
  334.         trans_gimage (tree, obj);         /* Bit Images an Bildschirm anpassen */
  335.       } /* if */
  336.  
  337.       if (xtype & DHEADER) ob->ob_y -= gl_hbox / 2;     /* group box */
  338.  
  339.       if (xtype & DHEIGHT)                              /* half height box */
  340.       {
  341.         ob->ob_height -= gl_hbox / 2;
  342.         if (! hires) ob->ob_height--;
  343.       } /* if */
  344.  
  345.       if (xtype & DCRBUTTON)
  346.       {
  347.         if (ob->ob_flags & RBUTTON)                     /* radio button */
  348.         {
  349.           radio_blk.ub_parm  = (LONG)ob->ob_spec;
  350.           ob->ob_y          += y_radio;
  351.           ob->ob_height      = h_radio;
  352. #if MSDOS | FLEXOS | DR_C | LATTICE_C | MW_C | TURBO_C
  353.           ob->ob_type        = G_USERDEF;
  354.           ob->ob_spec        = (LONG)&radio_blk;
  355. #endif
  356.         } /* if */
  357.         else                                            /* checkbox */
  358.         {
  359.           check_blk.ub_parm  = (LONG)ob->ob_spec;
  360.           ob->ob_y          += y_check;
  361.           ob->ob_height      = h_check;
  362. #if MSDOS | FLEXOS | DR_C | LATTICE_C | MW_C | TURBO_C
  363.           ob->ob_type        = G_USERDEF;
  364.           ob->ob_spec        = (LONG)&check_blk;
  365. #endif
  366.         } /* else */
  367.       } /* if */
  368.     } while (! (ob->ob_flags & LASTOB));
  369.   } /* if */
  370. } /* fix_objs */
  371.  
  372. /*****************************************************************************/
  373.  
  374. main()
  375. {
  376.   if (init_global (0, NULL, NULL, 0) == TRUE)
  377.     {    form_alert (1, "[3][Dieses Programm kann|nur von Interface|gestartet werden !][ Abbruch ]");
  378.         term_global ();
  379.     }
  380.  
  381.     return (0);
  382. }
  383.  
  384. /*****************************************************************************/
  385. /* Initialisieren des Moduls                                                 */
  386. /*****************************************************************************/
  387.  
  388. LOCAL BOOLEAN init_global (argc, argv, acc_menu, class)
  389. INT  argc;
  390. BYTE *argv [];
  391. BYTE *acc_menu;
  392. WORD class;
  393.  
  394. {    WORD   i;
  395.     STR128 rsc_name, s;
  396. #if GEM & (GEM2 | GEM3 | XGEM)
  397.   BYTE   *p;
  398. #endif
  399.  
  400.   i = appl_init ();                       /* Applikationsnummer besorgen */
  401.  
  402. #if (LATTICE_C | TURBO_C) | (GEM & (GEM2 | GEM3 | XGEM))
  403.   gl_apid = i;                            /* gl_apid nicht extern */
  404. #endif
  405.  
  406.   if (gl_apid < 0) return (FALSE);
  407.  
  408.   phys_handle = graf_handle (&gl_wbox, &gl_hbox, &gl_wattr, &gl_hattr); /* Handle des Bildschirms */
  409.   vdi_handle  = phys_handle;              /* Benutze physikalischen Bildschirm */
  410.   vwork_open  = FALSE;
  411.  
  412.   wind_get (DESK, WF_WXYWH, &desk.x, &desk.y, &desk.w, &desk.h);        /* Größe des Desktop */
  413.  
  414. #if GEM & GEM1
  415.   strcpy (rsc_name, RSC_NAME);                  /* Programm wurde vielleicht mit Pexec gestartet */
  416. #else
  417.   strcpy (rsc_name, app_name);
  418.   p = strrchr (rsc_name, SUFFSEP);              /* Programmname hat immer Suffix */
  419.   strcpy (p + 1, "RSC");
  420. #endif
  421.  
  422.   if (! rsrc_load (rsc_name))
  423.     {
  424.         strcpy (s, "[3][Resource-File|");
  425.         strcat (s, rsc_name);
  426.         strcat (s, "?][ EXIT ]");
  427.         form_alert (1, s);
  428.         return (FALSE);
  429.   } /* if */
  430.  
  431.   rsrc_gaddr (R_TREE, USERIMG, &userimg);       /* Adresse der Mac-Images */
  432.   rsrc_gaddr (R_TREE, HELP_EXT, &routines[3]);  /* Adresse der Hilfeseite */
  433.   fix_objs (userimg, FALSE);
  434.     
  435.   open_vwork ();                          /* Öffne virtuelle Workstation */
  436.  
  437.   return (TRUE);
  438. } /* init_global */
  439.  
  440. /*****************************************************************************/
  441. /* Terminieren des Moduls                                                    */
  442. /*****************************************************************************/
  443.  
  444. LOCAL BOOLEAN term_global ()
  445.  
  446. {
  447.   if (gl_apid >= 0)
  448.   {
  449.         rsrc_free ();                                  /* Resourcen freigeben */
  450.     close_vwork ();                     /* Workstation schließen */
  451.     appl_exit ();                       /* Applikation beenden */
  452.   } /* if */
  453.  
  454.   return (TRUE);
  455. } /* term_global */
  456.  
  457. /*****************************************************************************/
  458. /* Öffne virtuelle Workstation                                               */
  459. /*****************************************************************************/
  460.  
  461. LOCAL VOID open_vwork ()
  462.  
  463. {
  464.   WORD i;
  465.   WORD work_in [11];
  466.   WORD work_out [57];
  467.  
  468.   if (! vwork_open)
  469.   {
  470.     vwork_open = TRUE;
  471.  
  472.     for (i = 0; i < 10; work_in [i++] = 1);
  473.     work_in [10] = RC;                         /* Raster Koordinaten */
  474.     vdi_handle = phys_handle;
  475.     v_opnvwk (work_in, &vdi_handle, work_out); /* Öffne virtuelle Workstation */
  476.  
  477. #if GEM & XGEM
  478.     vst_point (vdi_handle, 10, &i, &i, &i, &i);
  479. #endif
  480.  
  481.     vqt_attributes (vdi_handle, work_out);     /* Globale Zeichensatzgrößen */
  482.   } /* if */
  483. } /* open_vwork */
  484.  
  485. /*****************************************************************************/
  486. /* Schließe virtuelle Workstation                                            */
  487. /*****************************************************************************/
  488.  
  489. LOCAL VOID close_vwork ()
  490.  
  491. {
  492.   if (vwork_open)
  493.   {
  494.     v_clsvwk (vdi_handle);                      /* Workstation freigeben */
  495.     vdi_handle = phys_handle;                   /* Physikalischen Bildschirm benutzen */
  496.     vwork_open = FALSE;
  497.   } /* if */
  498. } /* close_vwork */
  499.  
  500. /*****************************************************************************/
  501.  
  502. LOCAL VOID trans_gimage (tree, obj)
  503. OBJECT *tree;
  504. WORD   obj;
  505.  
  506. {
  507.   ICONBLK *piconblk;
  508.   BITBLK  *pbitblk;
  509.   WORD    *taddr;
  510.   WORD    wb, hl, type;
  511.  
  512.   type = tree [obj].ob_type;
  513.  
  514.   if (type == G_ICON)
  515.   {
  516.     piconblk = (ICONBLK *)tree [obj].ob_spec;
  517.     taddr    = piconblk->ib_pmask;
  518.     wb       = piconblk->ib_wicon;
  519.     wb       = wb >> 3;
  520.     hl       = piconblk->ib_hicon;
  521.  
  522.     vdi_trans (taddr, wb, taddr, wb, hl);
  523.  
  524.     taddr = piconblk->ib_pdata;
  525.   } /* if */
  526.   else
  527.   {
  528.     pbitblk = (BITBLK *)tree [obj].ob_spec;
  529.     taddr   = pbitblk->bi_pdata;
  530.     wb      = pbitblk->bi_wb;
  531.     hl      = pbitblk->bi_hl;
  532.   } /* else */
  533.  
  534.   vdi_trans (taddr, wb, taddr, wb, hl);
  535. } /* trans_gimage */
  536.  
  537. /*****************************************************************************/
  538.  
  539. LOCAL VOID xywh2rect (x, y, w, h, rect)
  540. WORD x, y, w, h;
  541. RECT *rect;
  542.  
  543. {
  544.   rect->x = x;
  545.   rect->y = y;
  546.   rect->w = w;
  547.   rect->h = h;
  548. } /* xywh2rect */
  549.  
  550. /*****************************************************************************/
  551.  
  552. LOCAL VOID set_clip (clipflag, size)
  553. BOOLEAN     clipflag;
  554. CONST RECT *size;
  555.  
  556. {
  557.   RECT r;
  558.   WORD xy [4];
  559.  
  560.   if (size == NULL)
  561.     rc_copy (&desk, &r);                /* Nichts definiert, nimm Desktop */
  562.   else
  563.     rc_copy (size, &r);                 /* Benutze definierte Größe */
  564.  
  565.   rc_copy (&r, &clip);                  /* Rette aktuelle Werte */
  566.  
  567.   if (rc_intersect (&desk, &r))         /* Nur auf Desktop zeichnen */
  568.     rect2array (&r, xy);
  569.   else
  570.     xywh2array (0 ,0 ,0 ,0, xy);        /* Nichts zeichnen */
  571.  
  572.   vs_clip (vdi_handle, clipflag, xy);   /* Setze Rechteckausschnitt */
  573. } /* set_clip */
  574.  
  575. /*****************************************************************************/
  576.  
  577. LOCAL VOID vdi_fix (pfd, theaddr, wb, h)
  578. MFDB *pfd;
  579. VOID *theaddr;
  580. WORD wb, h;
  581.  
  582. {
  583.   pfd->mp  = theaddr;
  584.   pfd->fwp = wb << 3;
  585.   pfd->fh  = h;
  586.   pfd->fww = wb >> 1;
  587.   pfd->np  = 1;
  588. } /* vdi_fix */
  589.  
  590. /*****************************************************************************/
  591.  
  592. LOCAL VOID vdi_trans (saddr, swb, daddr, dwb, h)
  593. WORD *saddr;
  594. WORD swb;
  595. WORD *daddr;
  596. WORD dwb;
  597. WORD h;
  598.  
  599. {
  600.   MFDB src, dst;
  601.  
  602.   vdi_fix (&src, saddr, swb, h);
  603.   src.ff = TRUE;
  604.  
  605.   vdi_fix (&dst, daddr, dwb, h);
  606.   dst.ff = FALSE;
  607.  
  608.   vr_trnfm (vdi_handle, &src, &dst);
  609. } /* vdi_trans */
  610.  
  611. /*****************************************************************************/
  612.  
  613. LOCAL VOID rc_copy (ps, pd)
  614. CONST REG RECT *ps;
  615. REG RECT       *pd;
  616.  
  617. {
  618.   pd->x = ps->x;
  619.   pd->y = ps->y;
  620.   pd->w = ps->w;
  621.   pd->h = ps->h;
  622. } /* rc_copy */
  623.  
  624. /*****************************************************************************/
  625.  
  626. LOCAL BOOLEAN rc_intersect (p1, p2)
  627. CONST REG RECT *p1;
  628. REG RECT       *p2;
  629.  
  630. {
  631.   REG WORD tx, ty, tw, th;
  632.  
  633.   tw = min (p2->x + p2->w, p1->x + p1->w);
  634.   th = min (p2->y + p2->h, p1->y + p1->h);
  635.   tx = max (p2->x, p1->x);
  636.   ty = max (p2->y, p1->y);
  637.  
  638.   p2->x = tx;
  639.   p2->y = ty;
  640.   p2->w = tw - tx;
  641.   p2->h = th - ty;
  642.  
  643.   return ((tw > tx) && (th > ty));
  644. } /* rc_intersect */
  645.  
  646. /*****************************************************************************/
  647.  
  648. LOCAL VOID rect2array (rect, array)
  649. CONST RECT *rect;
  650. WORD       *array;
  651.  
  652. {
  653.   *array++ = rect->x;
  654.   *array++ = rect->y;
  655.   *array++ = rect->x + rect->w - 1;
  656.   *array   = rect->y + rect->h - 1;
  657. } /* rect2array */
  658.  
  659. /*****************************************************************************/
  660.  
  661. LOCAL VOID xywh2array  (x, y, w, h, array)
  662. WORD x, y, w, h;
  663. WORD *array;
  664.  
  665. {
  666.   *array++ = x;
  667.   *array++ = y;
  668.   *array++ = x + w - 1;
  669.   *array   = y + h - 1;
  670. } /* xywh2array */
  671.  
  672. /*****************************************************************************/
  673.  
  674. GLOBAL LONG pinit_obfix (status)
  675. BOOLEAN status;
  676.  
  677. {
  678.     if (status == TRUE)
  679.     {    if (!init_global (0, NULL, NULL, 0))
  680.             return (0L);
  681.         else
  682.             return ((LONG)routines);
  683.     }
  684.     else
  685.         term_global ();
  686.     
  687.     return (0L);
  688. }
  689.